package {
	//import flashx.textLayout.elements.BreakElement;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import flash.utils.*;

	/**
	 * @author lenovo
	 */
	public class Navegari extends Sprite {
		private var game: Game;
		private var masc : Sprite;
		private var scaleWindow : Number = 0.8;
		private var toolbar : Toolbar;
		private var pez : Pez;
		private var countPoints : int;
		private var entro : Boolean;
		private var paquete : Paquete;
		private var paquetes : Array = new Array();
		
		public function Navegari() : void {
			toolbar = new Toolbar();
			addChild(toolbar);
				
			pez = new Pez();
			paquete = new Paquete();
			paquetes.push(paquete);
			masc = new Sprite();
			masc.graphics.beginFill(0xff00ff);
			masc.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
			masc.graphics.endFill();
			masc.scaleX = scaleWindow;
			masc.scaleY = scaleWindow;
			
			graphics.beginFill(0x0000ff);
			graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
			graphics.endFill();
			
			game = new Game(this);
			game.scaleX = scaleWindow;
			game.scaleY = scaleWindow;
			
			masc.x = (stage.stageWidth - masc.width)/2;
			masc.y = stage.stageHeight - masc.height;
			
			game.x = (stage.stageWidth - masc.width)/2;
			game.y = stage.stageHeight - masc.height;
			trace(game.width,'   ', game.height);
			trace(masc.width,'   ', masc.height);
			trace(game.x,'   ', game.y);
			trace(masc.x,'   ', masc.y);
			addChild(game);
			game.mask = masc;
			
			stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}		
		
		private function onEnterFrame(e : Event):void{
			toolbar.score.text = 'Bonus: ' + game.packs.toString();
			toolbar.coins.text = 'Monedas: ' + game.money.toString();
		}
		
	}
}
